package com.yunchao.feature.business.data.datasource.database

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Update
import com.yunchao.feature.business.data.datasource.database.model.BusinessInfoEntityModel

@Dao
internal interface BusinessInfoDao {

    @Query("SELECT * FROM business_info ORDER BY id DESC LIMIT 1")
    suspend fun query(): BusinessInfoEntityModel?


    @Query("SELECT * FROM business_info where tranTypeID=:tranTypeID and tranID=:tranID")
    suspend fun query(
        tranTypeID: String,
        tranID: String
    ): BusinessInfoEntityModel?

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insert(entityModel: BusinessInfoEntityModel)

    @Update
    suspend fun update(entityModel: BusinessInfoEntityModel)

    @Query("DELETE FROM business_info")
    suspend fun deleteAll()
}